package com.llb666.e.shop.api.dto;

import com.llb666.e.shop.domain.entity.PayOrders;
import com.llb666.e.shop.infracore.enums.PaymentStatus;
import com.llb666.e.shop.infracore.enums.YesOrNo;
import lombok.Data;

import java.util.Date;

/**
 * 下单dto.
 *
 * @author llb666
 * @date 2022/9/15 23:47
 */
@Data
public class MerchantOrdersDto {

    /**
     * 商户订单号.
     */
    private String merchantOrderId;
    /**
     * 商户方的发起用户的用户主键id.
     */
    private String merchantUserId;
    /**
     * 实际支付总金额（包含商户所支付的订单费邮费总额）.
     */
    private Integer amount;
    /**
     * 支付方式 1:微信   2:支付宝.
     */
    private Integer payMethod;
    /**
     * 支付成功后的回调地址（学生自定义）.
     */
    private String returnUrl;

    public PayOrders covert (String paymentOrderId){
        PayOrders paymentOrder = new PayOrders();
        paymentOrder.setId(paymentOrderId);
        paymentOrder.setPayStatus(PaymentStatus.WAIT_PAY.type);
        paymentOrder.setComeFrom("小鹅拼拼");
        paymentOrder.setIsDelete(YesOrNo.NO.type);
        paymentOrder.setCreateTime(new Date());
        paymentOrder.setMerchantOrderId(this.getMerchantOrderId());
        paymentOrder.setMerchantUserId(this.getMerchantUserId());
        paymentOrder.setAmount(this.getAmount());
        paymentOrder.setPayMethod(this.getPayMethod());
        paymentOrder.setReturnUrl(this.getReturnUrl());
        return paymentOrder;
    }
}
